<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<script src="/static/admin/ueditor/ueditor.config.js"></script>
<script src="/static/admin/ueditor/ueditor.all.min.js"></script>
<script src="/static/admin/ueditor/lang/zh-cn/zh-cn.js"></script>
<link rel="stylesheet" type="text/css" href="/static/admin/ueditor/themes/default/css/ueditor.css"/>
<link rel="stylesheet" href="/static/admin/ueditor/third-party/video-js/video-js.min.css">
<script type="text/javascript" src="/static/admin/ueditor/third-party/video-js/video.js"></script>
<script type="text/javascript" src="/static/admin/ueditor/third-party/video-js/video.dev.js"></script>
<script type="text/javascript" src="/static/admin/ueditor/third-party/video-js/video-js.swf"></script>
<script type="text/javascript" src="/static/admin/ueditor/third-party/video-js/video-js.css"></script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->

<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-adsList-edit"
			th:object="${adsList}">
			<input id="adsListId" name="adsListId" th:field="*{adsListId}"
				type="hidden">
			<div class="form-group">
				<label class="col-sm-3 control-label">广告标题：</label>
				<div class="col-sm-8">
					<input id="adsListTitle" name="adsListTitle"
						th:field="*{adsListTitle}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">广告封面：</label>
				<div class="col-sm-8">
				<input th:field="*{adsListImage}" id="imgPath" type="hidden">
				<label for="adsListImage" class=" btn btn-success">点击修改</label>
					<input id="adsListImage" type="file" name="file" accept="Image/*" style="display:none"/>
					
					<div>
					<br>
					<img  width="470px" height="300px" id="imageShow">
					</div>	
					
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">广告链接：</label>
				<div class="col-sm-8">
					<input id="adsListUrl" name="adsListUrl" th:field="*{adsListUrl}"
						class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">详情：</label>
				<div class="col-sm-8">
					<!--<input id="adsListDetail" name="adsListDetail"
						th:field="*{adsListDetail}" class="form-control" type="text">-->
                <textarea name="adsListDetail" id="adsListDetail" th:field="*{adsListDetail}" style="width: 400px; height: 200px; margin: 0 auto;"></textarea>
				</div>
			</div>
			<div class="form-group">
				<input type="hidden" th:value="*{adsId}" id="adsIdVal"> <label
					class="col-sm-3 control-label">所属广告位：</label>
				<div class="col-sm-8">
					<select id="adsId" name="adsId" class="form-control">

					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">使用状态：</label>
				<div class="col-sm-8">
					<select id="adsListState" name="adsListState"
						th:field="*{adsListState}" class="form-control">
						<option value='0' label="可用"></option>
						<option value='1' label="停用"></option>
					</select>
				</div>
			</div>
			<!-- <div class="form-group">	
				<label class="col-sm-3 control-label">发布时间：</label>
				<div class="col-sm-8">
					<input id="adsListPublic" name="adsListPublic" th:field="*{adsListPublic}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">创建人：</label>
				<div class="col-sm-8">
					<input id="createBy" name="createBy" th:field="*{createBy}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">创建时间：</label>
				<div class="col-sm-8">
					<input id="createTime" name="createTime" th:field="*{createTime}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">最后修改人：</label>
				<div class="col-sm-8">
					<input id="updateBy" name="updateBy" th:field="*{updateBy}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">修改时间：</label>
				<div class="col-sm-8">
					<input id="updateTime" name="updateTime" th:field="*{updateTime}" class="form-control" type="text">
				</div>
			</div>     -->
			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<input id="remark" name="remark" th:field="*{remark}"
						class="form-control" type="text">
				</div>
			</div>
		</form>
	</div>
	<div th:include="include::footer"></div>
	<script type="text/javascript">
		var prefix = ctx + "gxgw_modules/adsList";
		var path = $('#imgPath').val();
		 $('#imageShow').attr('src','/profile/adsList/'+path+'');
		
		$("#form-adsList-edit").validate({
			rules:{
				adsListTitle:{
					required:true
				},
				adsListUrl:{
					required:true,
					url:true
				},
				getName:{
					required:true
				},
				adsListState:{
					required:true
				}
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	var formData = new FormData($('#form-adsList-edit')[0]);
	        	
	        	 $.ajax({
	        	        url: prefix+"/edit",
	        	        data: formData,
	        	        type: "post",
	        	        async: false,
	        	        processData: false,
	        	        contentType: false,
	        	        success: function(result) {
		        	        
		        	        $.operate.successCallback(result);
	        	        }
	        	    })
	        }
	    }
		//图片回显
		 $('#adsListImage').on('change', function() {
			
		        var reader = new FileReader();
		         
		        reader.onload = function(e) {
		            imgSrc = e.target.result;
		            
		            //根据MIME判断上传的文件是不是图片类型
		            if((imgSrc).indexOf("image/")==-1){
		                $.modal.alertWarning("文件格式错误，请上传图片类型,如：JPG,JEPG,GIF,PNG后缀的文件。");
		            } else {
                        
		             
		              $('#imageShow').attr('src',imgSrc);
		            }
		        }
		        reader.readAsDataURL(this.files[0]);
		    });
		 adsName();
         function adsName(){
         	$.ajax({
                 type: "post",
                 url:prefix + "/selectAdsName",
                 dataType: "json",
                 success: function(res){
                     if (null != res) {
                        var html= '';
                         Object.keys(res).forEach(function(key){
                             html += '<option value="' + res[key].adsId + '" label="'+ res[key].adsName+'"></option>';
                         });
                         $('#adsId').html(html);
                         var Flag=$("#adsIdVal").val();
                         //根据值让option选中 
                             $("#adsId option[value='"+Flag+"']").attr("selected","selected");
                  
                     }
                     }
              });
         }

       
	</script>

</body>
	<script type="text/javascript">
  UE.getEditor('adsListDetail');
   
</script>
</html>
